﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormsAppTest.Service;

namespace WinFormsAppTest.Control
{
    public partial class UserFilesSearchControl : UserControl
    {
        private int userid;

        public UserFilesSearchControl()
        {
            InitializeComponent();
        }

        public UserFilesSearchControl(int id)
        {
            userid = id;
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timelabel.Text = DateTime.Now.ToString("G");
        }

        private void SearchControl_Load(object sender, EventArgs e)
        {
            //调整时间控件
            timer1.Interval = 1000;
            timer1.Start();
            //

            //调整界面的大小使得所有的控件显示出来
            this.Size = new Size(1029, 501);
            //

            //开始添加表格中的数据
            //FormService formservice = new FormService();
            //FilesdataGridView = formservice.Form_Filesdata_Loading(FilesdataGridView);
            DataGridViewClass dataGridViewClass = new DataGridViewClass();
            FilesdataGridView = dataGridViewClass.GetFilesDataByUserId(FilesdataGridView,userid);
            //
        }

        //private void searchtextBox_Enter(object sender, EventArgs e)
        //{
        //    if (searchtextBox.Text == "请输入搜索内容")
        //        searchtextBox.Text = "";
        //    searchtextBox.ForeColor = Color.Black;
        //}

        //private void searchtextBox_Leave(object sender, EventArgs e)
        //{
        //    if (searchtextBox.Text == "")
        //    {
        //        searchtextBox.Text = "请输入搜索内容";
        //        searchtextBox.ForeColor = Color.Gray;
        //    }
        //}

        //private void searchbutton_Click(object sender, EventArgs e)
        //{
        //    if (string.IsNullOrWhiteSpace(searchtextBox.Text)
        //       || searchcomboBox.SelectedItem == null)//判断复选框是否选中
        //    {
        //        FilesdataGridView.Rows.Clear();
        //        DataGridViewClass dataGridView = new DataGridViewClass();
        //        FilesdataGridView = dataGridView.GetFilesData(FilesdataGridView);
        //    }
        //    else
        //    {
        //        string combox = searchcomboBox.SelectedItem.ToString();
        //        FilesdataGridView.Rows.Clear();
        //        if (int.TryParse(searchtextBox.Text, out int number)
        //            && combox == "档案id")
        //        {
        //            if (number != 0 && searchtextBox.Text != "请输入搜索内容")
        //            {
        //                DataGridViewClass dataGridView = new DataGridViewClass();
        //                FilesdataGridView = dataGridView.GetFilesDataById(FilesdataGridView, number);
        //            }
        //            else
        //            {
        //                DataGridViewClass dataGridView = new DataGridViewClass();
        //                FilesdataGridView = dataGridView.GetFilesData(FilesdataGridView);
        //            }

        //        }
        //        else if (combox == "户口情况")
        //        {
        //            if (searchtextBox.Text != "" && searchtextBox.Text != "请输入搜索内容")
        //            {
        //                DataGridViewClass dataGridView = new DataGridViewClass();
        //                FilesdataGridView = dataGridView.GetFilesDataByHouse(FilesdataGridView, searchtextBox.Text);
        //            }
        //            else
        //            {
        //                DataGridViewClass dataGridView = new DataGridViewClass();
        //                FilesdataGridView = dataGridView.GetFilesData(FilesdataGridView);
        //            }

        //        }
        //        else if (combox == "用户id")
        //        {
        //            if (number != 0 && searchtextBox.Text != "请输入搜索内容")
        //            {
        //                //MessageBox.Show(""+number);
        //                DataGridViewClass dataGridView = new DataGridViewClass();
        //                FilesdataGridView = dataGridView.GetFilesDataByUserId(FilesdataGridView, number);
        //            }
        //            else
        //            {
        //                DataGridViewClass dataGridView = new DataGridViewClass();
        //                FilesdataGridView = dataGridView.GetFilesData(FilesdataGridView);
        //            }

        //        }
        //        else
        //        {
        //            DataGridViewClass dataGridView = new DataGridViewClass();
        //            FilesdataGridView = dataGridView.GetFilesData(FilesdataGridView);
        //        }
        //    }
        //}
    }
}
